import request from './request.js';

const key = '125c54f7141d0ef8c0c107fd1ad3cf84';

//通过城市名查询 adcode
export const getCityAdcode = (value) => {
  return request({
    method: 'GET',
    url: `/geocode/geo?address=${value}&key=${key}`,
  });
};

//通过 ip 地址查询所在城市
export const getCityByIp = (ip) => {
  return request({
    method: 'GET',
    url: `/ip?ip=${ip}&key=${key}`,
  });
};

//通过 adcode 查询城市天气
//extensions 气象类型 base:返回实况天气 all:返回预报天气
export const getCityWeather = (adcode, extensions) => {
  return request({
    method: 'GET',
    url: `/weather/weatherInfo?city=${adcode}&key=${key}&extensions=${extensions}`,
  });
};
